import { ref } from 'vue'
import { defineStore } from 'pinia'

export interface UserInfo {
  id: number
  name: string
  deptId: number
  deptName: string
  title: string
}

export const useUserStore = defineStore('user', () => {
  const userInfo = ref<UserInfo | null>(null)

  function setUserInfo(info: UserInfo) {
    userInfo.value = info
  }

  function clearUserInfo() {
    userInfo.value = null
  }

  return {
    userInfo,
    setUserInfo,
    clearUserInfo
  }
})